#ifndef _CAN_H_
#define _CAN_H_
#include "def.h"

#include "stm32f10x_can.h"

#define CAN1_RX_FIFO_SIZE	64
#define CAN1_TX_FIFO_SIZE	64
#define CAN2_RX_FIFO_SIZE	64
#define CAN2_TX_FIFO_SIZE	64

	typedef struct _CAN_INFO{
		BYTE accStatus;
		U8 LCD_Off;
		U8 CarLightStatus;
		U8 CarBackStatus;

		U8 Acc_id_s;
		U8 ACC_ON_cnt;
		U8 ACC_OFF_cnt;

		U8 Radar_F_1_Count;
		U8 Radar_F_2_Count;
		U8 Radar_F_3_Count;
		U8 Radar_F_4_Count;
		U8 Radar_R_1_Count;
		U8 Radar_R_2_Count;
		U8 Radar_R_3_Count;
		U8 Radar_R_4_Count;
		BOOL Radar_En;
		BOOL Radar_On;
		U32 RadarRecTime;

		U8 Air_Right_Temp;//0	Lo	0xFF	Hi	0xFE	Auto
		U8 Air_Left_Temp;
		U8 Air_Max;
		U8 Air_AC;
		U8 Air_AUTO;
		U8 Air_DUAL;
		U8 Air_Mode_Up;
		U8 Air_Mode_Left;
		U8 Air_Mode_Down;
		U8 Air_Speed;
		U8 Air_Vane;
		U8 Air_Front;
		U8 Air_RearSeatLock;
		U8 Air_LeftHeat;
		U8 Air_RightHeat;
		U8 Air_ON;
		U8 Air_Display;

		float Car_Speed;
	}CAN_INFO;

	#ifndef		_CAN_GLOBAL_
		#define		CAN_GLOBAL		extern
		
		EXPORT_FIFO_API(Can1RxFifo, CAN1_RX_FIFO_SIZE, CanRxMsg, u8)
		EXPORT_FIFO_API(Can1TxFifo, CAN1_TX_FIFO_SIZE, CanTxMsg, u8)
        
        EXPORT_FIFO_API(Can2RxFifo, CAN2_RX_FIFO_SIZE, CanRxMsg, u8)
		EXPORT_FIFO_API(Can2TxFifo, CAN2_TX_FIFO_SIZE, CanTxMsg, u8)
	#else
		#define		CAN_GLOBAL	

		NEW_FIFO(Can1RxFifo, CAN1_RX_FIFO_SIZE, CanRxMsg, u8)
		NEW_FIFO(Can1TxFifo, CAN1_TX_FIFO_SIZE, CanTxMsg, u8)
        NEW_FIFO(Can2RxFifo, CAN2_RX_FIFO_SIZE, CanRxMsg, u8)
        NEW_FIFO(Can2TxFifo, CAN2_TX_FIFO_SIZE, CanTxMsg, u8)
	#endif

void CAN0_ModuleWork(BOOL bOn);
	
void canFreeIdleProc(void);
void canInit(void);
void can2Init(void);
void can1DeInit(void);
void can2DeInit(void);
CAN_GLOBAL CAN_INFO canInfo;

#endif
